<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>/ht/">
<meta charset="UTF-8">
<title>Add ElementType</title>
<link rel="stylesheet" href="css/xiaoge.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/xiaogemsg.js"></script>
<script type="text/javascript" src="laydate/laydate.js"></script>
<script type="text/javascript">
	$(function(){
		//验证用户是否为空
		$("#carRMainName").bind("blur",function(){
			var carRMainName = $("#carRMainName").val().trim();
			if(carRMainName==null || carRMainName==""){
				xiaogemsg(200,"请输入客户名！",2000);
				$("#carRMainName").css("border-color","red");
			}else{
				$("#carRMainName").css("border-color","gray");
			}
		});
		
		//验证客户电话
		$("#carRMainPhone").bind("blur",function(){
			var carRMainPhone = $("#carRMainPhone").val().trim();
			var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
			
			if(carRMainPhone==null || carRMainName==""){
				xiaogemsg(200,"请输入客户联系电话！",2000);
				$("#carRMainPhone").css("border-color","red");
			}else{
				if(!reg.test(carRMainPhone)){
					xiaogemsg(200,"你输入的电话有误！",2000);
					$("#carRMainPhone").css("border-color","red");
				}else{
					$("#carRMainPhone").css("border-color","gray");
				}
			}
		});
		
		
		
		/* 保存 */
		$("#keep").click(function(){
			//入库时间验证
			$("#carRoomStartTime").bind("blur",function(){
				var carRoomStartTime = $("#carRoomStartTime").val().trim();
				if(carRoomStartTime==null || carRoomStartTime==""){
					xiaogemsg(200,"请输入选择入库时间！",2000);
					$("#carRoomStartTime").css("border-color","red");
					return false;
				}else{
					$("#carRoomStartTime").css("border-color","gray");
				}
			});
			var frm = $("#frm").serialize();
			$.post("../carRoomAction!addCarRoom.action",frm,function(data){
				
				if(data){
					xiaogemsg(200,"添加成功!",2000);
					parent.window.history.go(0);
				}else{
					xiaogemsg(200,"添加失败!",2000);
				}
			});
		});
		
		//关闭窗口
		$("#cancel").click(function(){
			closeThis();
		});
	});
	//关闭当前窗口的方法
	function closeThis(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
		return;
	}
</script>
</head>
<body>
	<form id="frm" action="" method="post">
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">服务车型:</label>
			</div>
			<select class="input" id="sermodel" name="carRoom.sermodel">
				<option value="奔驰">奔驰</option>
				<option value="宝马">宝马</option>
				<option value="宾利">宾利</option>
			</select>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">客户名称:</label>
			</div>
			<input type="text" class="input" id="carRMainName" name="carRoom.carRMainName" placeholder="*请输入用户名"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">联系电话:</label>
			</div>
			<input type="text" class="input" id="carRMainPhone" name="carRoom.carRMainPhone" placeholder="*请输入用户名"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">服务类型:</label>
			</div>
			<select class="input" id="serverType" name="carRoom.serverType">
				<option value="汽车保养">汽车保养</option>
				<option value="汽车维修">汽车维修</option>
				<option value="配件更换">配件更换</option>
				<option value="机油更换">机油更换</option>
			</select>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">入库时间:</label>
			</div>
			<input type="text" class="input" id="carRoomStartTime" name="carRoom.carRoomStartTime" placeholder="*请输入用户名"/>
		</div>
		
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">备&nbsp;&nbsp;&nbsp;&nbsp;注:</label>
			</div>
			<textarea class="input" style="height: 120px;" id="remark" name="carRoom.remark">无</textarea>
		</div>
		<div style="height: 120px;"></div>
		<div class="xiaoge-div-input">
			<div style="margin-right: 20px;float:right;">
				<input type="button" class="xiaoge-btn" id="keep" value=" 保 存 ">
				<input type="button" class="xiaoge-btn" id="cancel" style="margin-left:10px;background-color:#FF5722;" value=" 取 消 ">
			</div>
		</div>
	</form>
</body>
	<script>
		lay('#version').html('-v'+ laydate.v);
		//执行一个laydate实例
		laydate.render({
		  elem: '#carRoomStartTime' //指定元素
		});
	</script>
</html>